package com.ac.app.web.action.pick;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ac.app.dm.PickRecord;
import com.caac.core.util.DateUtils;
import com.caac.core.web.action.BaseAction;
import com.caac.core.web.form.BaseForm;
import com.ac.app.web.form.PkRecordForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright AgileCentury 2008</p>
 * <p>Company: AgileCentury </p>
 * @author <a href="mailto:ac@agilecentury.com">Agile</a>
 * @version 1.0
 */

public class EditPkRecordAction extends BaseAction {

	protected ActionForward doExecute(ActionMapping mapping, BaseForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws java.lang.Exception {
		PkRecordForm myForm = (PkRecordForm) form;
		String id = request.getParameter("id");
		if (id == null) {
			myForm.setContent(myForm.getContent());
			myForm.setKwdCon(myForm.getKwdCon());
			myForm.setSrcName(myForm.getSrcName());
			myForm.setSubName(myForm.getSubName());
			myForm.setPubDate(DateUtils.convertToString("yyyy-MM-dd HH:mm",
					new Date()));
		} else {
			PickRecord dm = (PickRecord) this.getBaseManager()
					.getObjectById(PickRecord.class, id);
			myForm.setPickRecord(dm);
			myForm.setPubDate(DateUtils.convertToString("yyyy-MM-dd",
					dm.getPrjBegdate()));
            myForm.setPickTime(DateUtils.convertToString("yyyy-MM-dd",
                    dm.getPrjEnddate()));
            //myForm.setSubs(dm.getSubName().split(","));
		}
		return forward(mapping);
	}
}
